<template>
  <Modal title="已开手牌" :width="800" :show-confirm-button="false">
    <div class="opened-cards-modal">
      <div class="search-form">
        <a-row :gutter="16">
          <a-col :span="8">
            <a-input
              v-model:value="searchForm.cardNumber"
              placeholder="手牌号"
            />
          </a-col>
          <a-col :span="8">
            <a-select v-model:value="searchForm.status" placeholder="手牌状态">
              <a-select-option value="">全部</a-select-option>
              <a-select-option value="occupied">占用</a-select-option>
              <a-select-option value="idle">空闲</a-select-option>
            </a-select>
          </a-col>
          <a-col :span="8">
            <a-button type="primary">搜索</a-button>
          </a-col>
        </a-row>
      </div>

      <div class="cards-table">
        <a-table
          :columns="tableColumns"
          :data-source="cardsData"
          :pagination="false"
          size="small"
        />
        <div class="table-footer">
          <span>数量: {{ cardsData.length }}</span>
          <a-button type="primary">打印</a-button>
        </div>
      </div>
    </div>
  </Modal>
</template>

<script setup lang="ts">
import { ref } from 'vue';

import { useVbenModal } from '@vben/common-ui';

defineOptions({
  name: 'OpenedCardsModal',
});

const searchForm = ref({
  cardNumber: '',
  status: '',
});

const tableColumns = [
  { title: '手牌号', dataIndex: 'cardNumber', key: 'cardNumber' },
  { title: '开牌时间', dataIndex: 'openTime', key: 'openTime' },
  { title: '消费金额', dataIndex: 'consumption', key: 'consumption' },
  { title: '状态', dataIndex: 'status', key: 'status' },
];

const cardsData = ref([
  {
    key: '1',
    cardNumber: '8001',
    openTime: '2018/01/01 13:24',
    consumption: '¥124.00',
    status: '占用',
  },
]);

const [Modal, modalApi] = useVbenModal({
  showCancelButton: false,
  showConfirmButton: false,
  async onOpenChange(isOpen) {
    if (!isOpen) {
      return;
    }
    searchForm.value = {
      cardNumber: '',
      status: '',
    };
  },
});

const handleCancel = () => {
  modalApi.close();
};
</script>

<style scoped>
.opened-cards-modal {
  padding: 20px 0;
}

.search-form {
  padding: 15px;
  margin-bottom: 20px;
  background: #f5f5f5;
  border-radius: 6px;
}

.cards-table {
  margin-bottom: 20px;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 15px;
  font-size: 14px;
  color: #666;
}
</style>
